package com.timerecording.util;

import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * @author smz41
 * @description: TODO
 * @date 2023/6/19
 */
@Data
public class PageResultDTO<T> {

    /**
     * 当前页
     */
    @ApiModelProperty(value = "当前页")
    private Long pageNum;

    /**
     * 每页的数量
     */
    @ApiModelProperty(value = "每页的数量")
    private Long pageSize;

    /**
     * 总记录数
     */
    @ApiModelProperty(value = "总记录数")
    private Long total;

    /**
     * 总页数
     */
    @ApiModelProperty(value = "总页数")
    private Long pages;

    /**
     * 结果集
     */
    @ApiModelProperty(value = "结果集")
    private List<T> list;

    @ApiModelProperty("是否为空")
    private Boolean emptyFlag;

    public static <T> PageResultDTO<T> empty() {
        PageResultDTO<T> resultDTO = new PageResultDTO<T>();
        resultDTO.setPageNum(0L);
        resultDTO.setPageSize(0L);
        resultDTO.setTotal(0L);
        resultDTO.setPages(0L);
        resultDTO.setList(Lists.newArrayList());
        resultDTO.setEmptyFlag(true);
        return resultDTO;
    }
}
